<template>
	<view ref="">
		<view :style="{ height: `${statusBarHeight}px` }"></view>
		<u-navbar
		  back-text="返回"
		  title="应急互动群"
		></u-navbar>
		<web-view v-if='url' ref="webView" class="webViewClass" :webview-styles="webviewStyles" :src="url"
			@message="getMessage"></web-view>
	
	</view>
</template>

<script>
	var wv; //计划创建的webview
	const info = uni.getSystemInfoSync();
	export default {
		data() {
			return {
				 statusBarHeight: this.$statusBarHeight,
				webviewStyles: {
					// top: "66px",
					width: "100%",
				},
				url: this.$store.state.chatgroup,
			}
		},
		onLoad(){
			uni.onKeyboardHeightChange(this.onKeyboardHeightChange);
		},
		onUnload(){
			uni.offKeyboardHeightChange(this.onKeyboardHeightChange);
		},
		mounted(){
			
			
			// #ifdef APP-PLUS
			var currentWebview = this.$scope.$getAppWebview(); //获取当前页面的webview对象
			let self = this;
			setTimeout(function () {
			  wv = currentWebview.children()[0];
			  wv.setStyle({
			    // scalable: true,
			    top: info.statusBarHeight + 40,
			    height: info.windowHeight - 80,
			  });
			  this.url = this.$store.state.chatgroup;
			  // self.initWebPage();
			}, 2000); //如果是页面初始化调用时，需要延时一下
			// #endif
		},
		methods: {
			onKeyboardHeightChange(res){
				const {height, duration} = res;
				if(height > 0){
					wv.setStyle({
						height: info.windowHeight - 80 -height
					});
				}else {
					wv.setStyle({
						height: info.windowHeight - 80
					});
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.webViewClass {
		height: calc(100vh);
		width: 100vw;
		// top: 66px !important;

	}
</style>
<style>
	* {
		/* 取消点击背景色显示蓝色 */
		-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
	}
</style>